
"use strict";

const Service = require("egg").Service;

class eclipsetable extends Service {
  // eclipsetable改成跟后台数据库的名字一致
  async findAll() {
    const result = await this.app.mysql.select("eclipsetable");
    return {
      code: 200,
      msg: "查找成功",
      data: result,
    };
  } // timesocietyitem
  async find(uid) {
    const result = await this.app.mysql.get("eclipsetable", { id: uid });
    if (result !== null) {
      return {
        code: 200,
        msg: "查找成功",
        data: Array(result),
      };
    }
    return {
      msg: "没有此条数据！",
    };
  }
  async test(page, limit, totalPageNum) {
    const offset = (page - 1) * limit;
    const result = await this.app.mysql.select("eclipsetable", {
      limit: parseInt(limit),
      offset,
    });
    return {
      code: 200,
      msg: "查找成功",
      data: result,
    };
  }
}
'use strict';

const Service = require('egg').Service;

class eclipsetable extends Service { // eclipsetable改成跟后台数据库的名字一致
  async findAll() {
    const result = await this.app.mysql.select('eclipsetable');
    return {
      code: 200,
      msg: '查找成功',
      data: result,
    };
  }// timesocietyitem
  async find(uid) {
    const result = await this.app.mysql.get('eclipsetable', { id: uid });
    if (result !== null) {
      return {
        code: 200,
        msg: '查找成功',
        data: result,
      };
    }
    return {
      msg: '没有此条数据！',
    };


  }
  // 往后台传动系
  async create(params) {
    const cfg = {

      ...params,
    };
    const result = await this.app.mysql.insert("eclipsetable", cfg);
    return {
      code: 200,
      msg: "创建成功",

      ...params
    };
    const result = await this.app.mysql.insert('eclipsetable', cfg);
    return {
      code: 200,
      msg: '创建成功',

      data: result,
    };
  }
  async delete(uid) {

    const result = await this.app.mysql.delete("eclipsetable", { id: uid });
    return {
      code: 200,
      msg: "删除成功",
    }
    const result = await this.app.mysql.delete('eclipsetable', { id: uid });
    return {
      code: 200,
      msg: '删除成功',

      data: result,
    };
  }
  async update(uid, params) {

    console.log(uid, params);
    const cfg = {
      ...params,
    };
    const result = await this.app.mysql.update("eclipsetable", cfg);
    return {
      code: 200,
      msg: "更新成功",
    }
    const cfg = {
      ...params
    };
    const result = await this.app.mysql.update('eclipsetable', cfg);
    return {
      code: 200,
      msg: '更新成功',

      data: result,
    };
  }
  async findAll0(pass) {

    const result = await this.app.mysql.select("eclipsetable", {
    })
    const result = await this.app.mysql.select('eclipsetable', {

      where: { pass },
    });
    return {
      code: 200,

      msg: "查找成功",

      msg: '查找成功',

      data: result,
    };
  }
}

module.exports = eclipsetable;
